
// 渲染 商品详情页
(function(){
    // 获取详情页面地址
    let url = location.href
    console.log(url);
    
    let urlObj = getQueryString(url)
    console.log(urlObj.productid);

    // fetch请求 获取数据 带上从首页获取过来的 urlObj.productId 参数
    fetch('http://chst.vip:1234/api/getmoneyctrlproduct?productid=' + urlObj.productid)
        .then(function(response){
            return response.json();
        }).then(function(data){
            let res = data.result[0]
            // 图片地址 正则
            let regExp = /(?<=imgurl=)[^'"]*/;
            let img = regExp.exec(res.productImg2)[0]

            let ele = `
            <li>
                <div class="infor">
                    <div class="title">
                        <h4>${res.productName}</h4>
                    </div>
                    <div class="other">
                        <span class="mall">${res.productFrom} | ${res.productTime}</span>
                        <i>${res.productTips}</i>
                    </div>
                    <div class="container">
                        <img src="${img}" alt="">
                        <p>
                            ${res.productInfo}
                            ${res.productInfo1}
                            ${res.productInfo2}
                                
                        </p>
                    </div>
                    <div class="bigimg">
                        <img src="${img}" alt="">
                    </div>
                    <div class="city">
                        ${res.productCity}
                    </div>
                </div>
            </li> 
            `
            $('#info').html(ele)

            $('#comment').html(res.productComment)

        })





})();

